import { MeVo } from "./role/MeVo";
import { Role } from "./role/Role";
import { Server } from "./server/Server";

/**
 @name: DataCenter
 @desc: 数据中心
 @author: timoo
 @date: 2022/11/30
 */
class DataCenter {
    private static created: boolean = false;
    constructor() {
        if (DataCenter.created) {
            throw new Error("DataCenter 是单例");
        }
        DataCenter.created = true;
    }

    /**
     * 服务器相关
     */
    server: Server = new Server().init();
    /**
     * 角色相关
     */
    role: Role = new Role();

    playerOrders: number = 0

    //...其他游戏业务数据

    /**
     * 当前玩家角色信息的快捷访问方式
     */
    public get me(): MeVo {
        return this.role.me;
    }

    resetData() {
        this.me.clearData()
        this.server = new Server().init();
        this.role = new Role();
    }
}

/**
 * 数据中心
 */
export var G_Data = new DataCenter();
